package com.heima;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class Demo1 {
    @Test(456)
    public int num = 10;

    public static void main(String[] args) throws NoSuchFieldException {
        Class clazz = Demo1.class;
        Annotation[] annotations = clazz.getAnnotations();
        for (Annotation annotation : annotations) {
            if (annotation.annotationType() == Test.class) {
                Test test = (Test) annotation;
                System.out.println(test.aaa());
                System.out.println(test.value());

            }

        }
        //获取字段上定义的注解
        Field num = clazz.getField("num");
        Test tes = num.getAnnotation(Test.class);
        System.out.println(tes.value());


    }
}
